package com.viviet.mobileservices.business.impl;

import java.util.HashMap;
import java.util.Map;

import com.viviet.mobileservices.business.IMessageService;
import com.viviet.mobileservices.common.Constants;

public class MessageServiceImpl implements IMessageService {
	private Map<String, String> messages;
	
	public MessageServiceImpl() {
		messages = new HashMap<String,String>();
		//TODO: load message from message table;
		// to make mapping between message from core to mobile message
		
		// verify password
		
		messages.put("202302", Constants.TEMPORARY_LOCK);
		messages.put("203401", Constants.INVALID_PASSWORD);
		messages.put("203400", Constants.PASSWORD_CORRECT);
		messages.put("202301", Constants.INVALID_PASSWORD);
		messages.put("202306", Constants.NON_EXIST_ACCOUNT);
		
		// get balance
		
		// transfer money
		messages.put(Constants.TRAN_DESTINATION_ACCOUNT_IS_INVALID, Constants.TRAN_DESTINATION_ACCOUNT_IS_INVALID);
		messages.put("119904", Constants.TRAN_DESTINATION_ACCOUNT_IS_LOCK);
		messages.put("119905", Constants.TRAN_DESTINATION_ACCOUNT_IS_LOCK);
		messages.put("149907", Constants.TRAN_DESTINATION_ACCOUNT_THE_SAME_WITH_SENDER);
		messages.put("110301", Constants.TRAN_DEBIT_CREDIT_IS_NOT_CORRECT);
		messages.put("160404", Constants.TRAN_LESS_THAN_MIN_AMOUNT_PER_TRANSACTION);
		messages.put("160402", Constants.TRAN_GREAT_THAN_MAX_AMOUNT_PER_TRANSACTION);
		messages.put("160403", Constants.TRAN_GREAT_THAN_MAX_TRANSACTION_PER_DAY);
		messages.put("119906", Constants.TRAN_NOT_ENOUGH_MONEY);
		messages.put("119900", Constants.TRAN_SUCCESS);
		messages.put("202602", Constants.TRAN_FAILED);
		messages.put("119906", Constants.TRAN_NOT_ENOUGH_MONEY);
		
		// change password 
		messages.put("202300", Constants.CHANGE_PASSWORD_SUCCESS);
		messages.put("202301", Constants.OLD_PASSWORD_INVALID);
		messages.put("202303", Constants.NEW_OLD_PASSWORD_THESAME);
		messages.put("202304", Constants.NEW_PASSWORD_NOT_ENOUGH_LENG);
		messages.put("202307", Constants.NEW_PASSWORD_NOT_ENOUGH_LENG);
		messages.put("202305", Constants.NON_EXIST_ACCOUNT);

		
	}
	
	@Override
	public String getMessage(String messageCode) {
		return (messages == null)?null:messages.get(messageCode);
	}

}
